package com.xjscrm.console.web.role;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.xjscrm.console.param.BaseDto;
import com.xjscrm.console.param.role.SysRoleDto;
import com.xjscrm.console.param.role.SysRoleDtoQuery;
import com.xjscrm.console.param.role.SysRoleIdDto;
import com.xjscrm.console.service.customer.role.RoleService;
import com.xjscrm.console.vo.SysRoleVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Api(value = "角色权限管理", tags = "角色权限管理")
@RestController
@RequestMapping(value = "/role")
public class RoleController {
    @Autowired
    RoleService roleService;

    @ApiOperation(value = "新增角色", notes = "新增角色", response = Boolean.class)
    @PostMapping("/addRole")
    public Object addRole(@RequestBody SysRoleDto sysRoleDto)throws Exception{
       roleService.addRole(sysRoleDto);
       return true;
    }

    @ApiOperation(value = "修改角色", notes = "修改角色", response = Boolean.class)
    @PostMapping("/updateRole")
    public Object updateRole(@RequestBody SysRoleDto sysRoleDto)throws Exception{
        roleService.updateRole(sysRoleDto);
        return true;
    }

    @ApiOperation(value = "获取角色列表", notes = "获取角色列表", response = SysRoleVo.class)
    @PostMapping("/getRoleList")
    public Object getRoleList(@RequestBody SysRoleDtoQuery SysRoleDtoQuery)throws Exception{
       return   roleService.getRoleList(SysRoleDtoQuery);
    }

    @ApiOperation(value = "获取角色下拉", notes = "获取角色下拉", response = Map.class)
    @PostMapping("/getRoleDropdwon")
    public Object getRoleDropdwon(@RequestBody BaseDto baseDto)throws Exception{
        return   roleService.getRoleDropdwon(baseDto);
    }


    @ApiOperation(value = "删除角色", notes = "删除角色", response = Boolean.class)
    @PostMapping("/deleRole")
    public Object deleRole(@RequestBody SysRoleDto sysRoleDto)throws Exception{
           roleService.deleRole(sysRoleDto);
           return true;
    }


    @ApiOperation(value = "查询角色详情", notes = "查询角色详情", response = SysRoleVo.class)
    @PostMapping("/findSysRoleInfo")
    public Object findSysRoleInfo(@RequestBody SysRoleIdDto sysRoleIdDto){
        return roleService.findSysRoleInfo(sysRoleIdDto);
    }



}
